<style type="text/css">
  .export_table {
    padding: 2px 0px 3px 3px;
    text-align: left;
  }
</style>
<script type="text/javascript"> 
  function check_all_handler(el)
  {
    var checked_status = el.checked;
    $(".check_field").each(function()
    {
      this.checked = checked_status;
    });
  }
  
  function get_related(event,name){
    var check_default = $("#check_all").is(':checked');
    $.post(  
      "/admin_export/export_to_xls_related/?{{ get_variables }}",  
      {get_related: "True", rel_name: name, check_default: check_default},
      function(data){
        var element = $(event.target).parent();
        $(element).hide('fast');
        $(element).html(data);
        $(element).show('slow');
      }  
    );  
  }
  
  function submit_box() {
    $("#export_xls_form").overlay().close();
    $('select[name=action] option[value=""]').attr("selected", "selected");
  }
</script>   

<h2> Export {{ model_name }} </h2>
<form method="post" action="/admin_export/export_to_xls/?{{ get_variables }}">
  {% csrf_token %}
  <table>
    <tr class="export_table">
      <th class="export_table">
        <input type="checkbox" id="check_all" onclick="check_all_handler(this)"/>
      </th>
      <th class="export_table">
        Select All
      </th>
    </tr>
  
    {% include "admin_export/fields.html" %}
  </table>
  <input type="submit" name="xls" onclick='submit_box();' value="Submit"/>
  <!-- HACK to make sure the submit button isn't under the bottom bar--><br/><br/><br/>
</form>
